from rest_framework import serializers
from .models import Equipment


class EquipmentSerializer(serializers.ModelSerializer):

    class Meta:
        model = Equipment
        fields = '__all__'


class EquipmentOverviewSerializer(serializers.Serializer):
    id = serializers.IntegerField()
    name = serializers.CharField()
    category_id = serializers.IntegerField()
    address = serializers.CharField()
    state = serializers.CharField()
    department_id = serializers.IntegerField()
    department_name = serializers.CharField()
    leader_name = serializers.CharField()
    category_name = serializers.CharField()

    class Meta:
        fields = '__all__'


class StateAnalyzeSerializer(serializers.Serializer):
    category = serializers.CharField(source='category__name')
    state = serializers.CharField()
    count = serializers.IntegerField()

    class Meta:
        fields = '__all__'


class DepartmentAnalyzeSerializer(serializers.Serializer):
    department = serializers.CharField(source='department__name')
    count = serializers.IntegerField()

    class Meta:
        fields = '__all__'

